﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cashbook.Services;
using Xamarin.Forms;

namespace Cashbook
{
   
    public partial class ItemsPage : ContentPage
    {
		private BillsDataAccess dataAccess;

        public ItemsPage()
        {
           // _db = db;
            InitializeComponent();
            this.dataAccess = new BillsDataAccess();

            //listBill.ItemTemplate = new DataTemplate(typeof(BillCell));
            //listBill.RowHeight = 70;
            //BindingContext = viewModel = new ItemsViewModel();

    //        using(var _db = new DataAccess()){
				//listBill.ItemsSource = _db.GetBills();
            //}
          


        }

		protected override void OnAppearing()
		{
			base.OnAppearing();
			// The instance of CustomersDataAccess
			// is the data binding source
			this.BindingContext = this.dataAccess;
		}

       // async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
        //{
            //var item = args.SelectedItem as Item;
            //if (item == null)
            //    return;

            //await Navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(item)));

            // Manually deselect item
            //ItemsListView.SelectedItem = null;
        //}

        async void AddItem_Clicked(object sender, EventArgs e)
        {
            await Navigation.PushAsync(new NewItemPage());
        }

        //protected override void OnAppearing()
        //{
        //    base.OnAppearing();

        //    if (viewModel.Items.Count == 0)
        //        viewModel.LoadItemsCommand.Execute(null);
        //}
    }
}
